package mo.leetcode_top;

public class L125 {

    public boolean isPalindrome(String s) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            if (Character.isLetterOrDigit(s.charAt(i))) {
                builder.append(Character.toLowerCase(s.charAt(i)));
            }
        }
        int len = builder.length();
        for (int i = 0; i < len; i++) {
            if (builder.charAt(i) != builder.charAt(len-1-i)) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        L125 test = new L125();
        System.out.println(test.isPalindrome("OP"));
    }
}
